<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<script type="text/javascript">
	/**点击审核状态按钮时关联效果**/
    function changeIsPass(id){
        /**修改审核单选框选中状态**/
        $("input[name='isPass']").each(function(i) {
            $(this).removeAttr("checked");
        });
        $("#a_isPass_"+id).attr("checked","checked");
        if(id==0){
            $("#btMessage").html("<i style='color:red'>*</i>&nbsp;&nbsp;");
        }else{
            $("#btMessage").html("");
        }
        /**修改审核单选框选中状态**/
        var is_1 = document.getElementById("a_isPutSale_1");//不上架
        var is_2 = document.getElementById("a_isPutSale_2");//上架
        var is_3 = document.getElementById("a_isPutSale_3");//违规下架
        if(id==1){//审核通过  上架
            is_2.checked="checked";
            is_1.disabled="disabled";
            is_3.disabled="disabled";
            is_2.disabled="";
        }else if(id==3){//待审核
            is_1.checked="checked";
            is_2.disabled="disabled";
            is_3.disabled="disabled";
            is_1.disabled="";
        }else{//审核未通过  违规下架
            is_1.checked="checked";
            is_1.disabled="";
            is_2.disabled="disabled";
            is_3.disabled="";
        }
		//审核不通过时，默认选中不推荐、不显示
        var isRecommend_0 = document.getElementById("a_isRecommend_0");//不推荐
        var isShow_0 = document.getElementById("a_isShow_0");//不显示
        var isRecommend_1 = document.getElementById("a_isRecommend_1");//推荐
        var isShow_1 = document.getElementById("a_isShow_1");//显示
        if(id==0){//审核未通过
            isRecommend_0.checked="checked";
            isRecommend_1.disabled="disabled";
            isRecommend_0.disabled="";
            isShow_0.checked="checked";
            isShow_1.disabled="disabled";
            isShow_0.disabled="";
        }else{
            isRecommend_1.disabled="";
            isRecommend_0.disabled="";
            isShow_1.disabled="";
            isShow_0.disabled="";
        }
    }

    /**提交商品审核表单信息**/
    function submitForAuditProduct(){
        var form=$("#auditForm");
        var auditComment = $("#auditComment").val();
        var isPassValue = $("input[name='isPass'][checked]").val();
        var isShowValue=$("input[name='isShow'][type='radio']:checked").val();
        if(isPassValue==0&&(auditComment==null||auditComment=='')){
            showMsg("审核未通过时，未通过原因必填！");
        }else{
			var options = {
					url: form.attr("action"),
					type : "post",
					dataType:"json",
					success : function(data) {
						if(data.success==true){
							/** 自动关闭弹出模态框窗口**/
							$(".close").click();
							$("#tt").bootstrapTable('refresh');
							showMsg("保存成功！");
						}else{
							showMsg("保存失败！");
						}
					}
				};
			form.ajaxSubmit(options);
		}
    }

</script>

<!--添加编辑模态框（Modal） -->
<div class="modal fade" id="auditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button id="addOrEditBtn" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="auditModalLabel"></h5>
			</div>

			<!--审核商品开始-->
			<div class="modal-body">
				<form id="auditForm" method="post" action="${basePath}/back/shopProduct/auditProduct.sjson">
					<input id="a_productId" type="hidden" name="productId" value="">
					<input type="hidden" name="isTop" value="0" noclear="true"/>
					<table align="center" class="addOrEditTable table-bordered table" style="width:100%;">
						<tr>
							<td class="toright_td" width="150px">审核状态:&nbsp;&nbsp;</td>
							<td class="toleft_td">&nbsp;&nbsp;
								<input id="a_isPass_3"  type="radio" name="isPass" value="3" onclick="changeIsPass(this.value)"/>待审核&nbsp;&nbsp;&nbsp;
								<input id="a_isPass_1"  type="radio" name="isPass" value="1" onclick="changeIsPass(this.value)"/>审核通过&nbsp;&nbsp;&nbsp;
								<input id="a_isPass_0"  type="radio" name="isPass" value="0" onclick="changeIsPass(this.value)"/>未通过&nbsp;&nbsp;&nbsp;
							<td class="toright_td" width="150px">是否上架:&nbsp;&nbsp;</td>
							<td class="toleft_td">&nbsp;&nbsp;
								<input id="a_isPutSale_1"  type="radio" name="isPutSale" value="1"/>未上架&nbsp;&nbsp;&nbsp;
								<input id="a_isPutSale_2"  type="radio" name="isPutSale" value="2"/>上架&nbsp;&nbsp;&nbsp;
								<input id="a_isPutSale_3"  type="radio" name="isPutSale" value="3"/>违规下架
							</td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">是否推荐:&nbsp;&nbsp;</td>
							<td class="toleft_td">&nbsp;&nbsp;
								<input id="a_isRecommend_0"  type="radio" name="isRecommend" value="0"/>否&nbsp;&nbsp;&nbsp;
								<input id="a_isRecommend_1"  type="radio" name="isRecommend" value="1"/>是</td>
							<td class="toright_td" width="150px">是否显示在列表:&nbsp;&nbsp;</td>
							<td class="toleft_td">&nbsp;&nbsp;
								<input id="a_isShow_0"  type="radio" name="isShow" value="0"/>不显示&nbsp;&nbsp;&nbsp;
								<input id="a_isShow_1"  type="radio" name="isShow" value="1"/>显示
							</td>
						</tr>
						<tr>
							<td class="toright_td" width="150px"><span id="btMessage"></span>备注:&nbsp;&nbsp;</td>
							<td class="toleft_td" colspan="3"><textarea class="form-control input-sm" id="auditComment" type="text" name="auditComment" value=""></textarea></td>
						</tr>
						<tr>
					</table>
				</form>
			</div>
			<!--审核商品结束-->

			<div class="modal-footer">
				<button type="button" id="saveBtn" class="btn btn-primary"  onclick="submitForAuditProduct()">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
